
import BkRequestManager from "@/utils/BKRequestManage";
import type { Active, Cover_tags, Digg, logArticle } from "@/types/Active";
import type { BKResponse } from "@/types/Response";
import type { CommentApi, PostComment } from "@/types/Comment";
import type { search_data } from "@/types/Search";
import type { News } from "@/types/News";
export class ArticleAPI{
          //获取文章详情
          static getArticle(nid:string){
            return BkRequestManager.instance.request<BKResponse<Partial<Active>>>({
                  url:`api/Article_details/${nid}`
             })
          }
          //文章点赞Article_collects
          static Article_digg(nid:number){
            return BkRequestManager.instance.request<BKResponse<Digg>>({
                  url: `api/Article_digg/${nid}`,
                  method: 'put'
             })
          } 
          //文章收藏
          static Article_collects(nid:number){
            return BkRequestManager.instance.request<BKResponse<Digg>>({
                  url: `api/Article_collects/${nid}`,
                  method: 'put'
             })
          } 
          //判断用户是否收藏了该文章
          static iscollect_Article(nid:string){
            return BkRequestManager.instance.request<BKResponse<boolean>>({
              url: `api/isArticle_collect/${nid}`

             })
          } 
          //获取用户评论
          static getArticle_comment(nid:string){
            return BkRequestManager.instance.request<BKResponse<CommentApi[]>>({
              url: `api/Article_comment/${nid}`
             })
          } 
            //发表评论 
          static PostComments(data:PostComment){
            return BkRequestManager.instance.request<BKResponse<boolean>>({
              url: 'api/Article_commenter/', 
              data,
              method: 'post'
         })
          } 
          static DeletrComments(id:number){
            return BkRequestManager.instance.request<BKResponse<boolean>>({
              url: "api/Article_commenter/", data:{id}, method: 'delete'
         })
          } 
          //评论点赞
          static Coommit_digg(nid:number){
            return BkRequestManager.instance.request<BKResponse<Digg>>({
              url: `api/Comment_digg/${nid}`, method: 'put' 
         })
          } 
          //获取文章标签
          static getArticle_tags(){
            return BkRequestManager.instance.request<BKResponse<Cover_tags>>({
              url:"api/Article_tags/"
            })
          }
          //发布文章
          static publishArticle(data:logArticle){
           return BkRequestManager.instance.request({
             url:"api/Article_publish/",
             data,
             method: 'post'
            })
          }
          //编辑文章
          static editArticle(data:logArticle){
            return BkRequestManager.instance.request({
              url: 'api/Article_publish/', data, method: 'put' 
             })
           }    
           //文章搜索
           static searchArticle(data:search_data){
            return BkRequestManager.instance.request<BKResponse<Active[]>>({
              url: "api/isArticle_search/",
              data,
              method: 'post'
             })
           } 
           
    
       
}


